//
//  ViewController.m
//  UI02UIImageView
//
//  Created by dllo on 16/6/6.
//  Copyright © 2016年 dllo. All rights reserved.
//

#import "ViewController.h"

@interface ViewController ()

@end

@implementation ViewController

- (void)viewDidLoad {
    [super viewDidLoad];
    [self createImageView];
    [self createAnimationImage];
    
    
    // Do any additional setup after loading the view, typically from a nib.
}
-(void)createImageView{
    //创建图片对象
    // 如果是png 格式的图片可以省略后缀 其他格式的图片不可以省略
    UIImage *imge = [UIImage imageNamed:@"BackGround.png"];
    //创建图片视图
    UIImageView *backgroundImageView = [[UIImageView alloc] initWithImage:imge];
    //全屏显示
    backgroundImageView.frame  = [UIScreen mainScreen].bounds;
    [self.view addSubview:backgroundImageView];
    [backgroundImageView release];
}


-(void)createAnimationImage{
    UIImageView *animationImageView = [[UIImageView alloc] initWithImage:[UIImage imageNamed:@"BZombie.tiff"]];
    animationImageView.frame = CGRectMake(300, 100, 100, 200);
    [self.view addSubview:animationImageView];
    [animationImageView release];
    NSMutableArray *mutableArray = [NSMutableArray arrayWithArray:0];
    for (int i = 1; i <= 25; i++) {
        NSString *name = [NSString stringWithFormat:@"BZombie%d.tiff",i];
        UIImage *animationImage = [UIImage imageNamed:name];
        [mutableArray addObject:animationImage];
        //指定动画所用到的一组图片
        animationImageView.animationImages = mutableArray;
        //指定动画所需时间
        animationImageView.animationDuration = 2;
        //开始动画
        [animationImageView startAnimating];
    }
    
    
    UIImageView *animationImageView2 = [[UIImageView alloc] initWithImage:[UIImage imageNamed:@"zombie.tiff"]];
    animationImageView2.frame = CGRectMake(300, 300, 100, 200);
    [self.view addSubview:animationImageView2];
    [animationImageView2 release];
    NSMutableArray *mutableArray2 = [NSMutableArray arrayWithArray:0];
    for (int i = 0; i <= 21; i++) {
        NSString *name = [NSString stringWithFormat:@"zombie%d.tiff",i];
        UIImage *animationImage = [UIImage imageNamed:name];
        [mutableArray2 addObject:animationImage];
        animationImageView2.animationImages = mutableArray2;
        animationImageView2.animationDuration = 2;
        [animationImageView2 startAnimating];
    }
    
    
    UIImageView *animationImageView3 = [[UIImageView alloc] initWithImage:[UIImage imageNamed:@"gua.tiff"]];
    animationImageView3.frame = CGRectMake(30, 300, 100, 200);
    [self.view addSubview:animationImageView3];
    [animationImageView3 release];
    NSMutableArray *mutableArray3 = [NSMutableArray arrayWithArray:0];
    for (int i = 1; i <= 16; i++) {
        NSString *name = [NSString stringWithFormat:@"gua%d.tiff",i];
        UIImage *animationImage = [UIImage imageNamed:name];
        [mutableArray3 addObject:animationImage];
        animationImageView3.animationImages = mutableArray3;
        animationImageView3.animationDuration = 2;
        [animationImageView3 startAnimating];
    }


}


- (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}

@end
